package com.tarena.lbs.common.basic.converter;

import com.tarena.lbs.pojo.basic.bo.AreaBO;
import com.tarena.lbs.pojo.basic.dos.AreaDO;
import com.tarena.lbs.pojo.basic.vo.AreaVO;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class AreaConverter {

    public AreaVO bo2vo(AreaBO bo){
        if (null == bo){
            return null;
        }
        AreaVO AreaVO = new AreaVO();
        BeanUtils.copyProperties(bo,AreaVO);
        return AreaVO;
    }



    public AreaBO do2bo(AreaDO AreaDO) {
        if (null == AreaDO){
            return null;
        }
        AreaBO AreaBO = new AreaBO();
        BeanUtils.copyProperties(AreaDO,AreaBO);
        return AreaBO;
    }


    public List<AreaBO> doList2boList(List<AreaDO> doList ){
        List<AreaBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        for (AreaDO areaDO : doList) {
            AreaBO areaBO = new AreaBO();
            BeanUtils.copyProperties(areaDO,areaBO);
            boList.add(areaBO);
        }
        return boList;
    }

    public List<AreaVO> boList2VoList(List<AreaBO> boList ){
        List<AreaVO> areaVoList = new ArrayList<>();
        if (CollectionUtils.isEmpty(boList)) {
            return areaVoList;
        }
        for (AreaBO areaBO : boList) {
            AreaVO areaVO = new AreaVO();
            BeanUtils.copyProperties(areaBO,areaVO);
            areaVoList.add(areaVO);
        }
        return areaVoList;
    }

}
